<?php
$this->jQuery()->enable();
$this->headLink()->prependStylesheet('/js/jquery/css/themes/base/jquery.ui.all.css');
$this->headScript() ->appendFile('/js/jquery/jquery-ui-1.8.12.custom.min.js')
					->appendFile('/js/jquery/ui/jquery.ui.widget.js')
					->appendFile('/js/jquery/ui/jquery.ui.core.js')					
					->appendFile('/js/jquery/ui/jquery.ui.dialog.js')					
					->appendFile('/js/jquery/ui/jquery.ui.draggable.js')
					->appendFile('/js/jquery/ui/jquery.ui.position.js')
					->appendFile('/js/jquery/ui/jquery.ui.resizable.js')
					->appendFile('/js/jquery/ui/jquery.ui.mouse.js')
					->appendFile('/js/jquery/ui/jquery.ui.button.js')					
					->appendFile('/js/geralAjax.js');
					

$this->headScript()->appendScript("
$(document).ready(function(){
 $('#confirme').dialog({
        height: 140,
        autoOpen: false,
        modal: true,
        resizable: false});
        $('input#Adicionar').button();               
        $('input#salvar').button();
      
});");
$translator = Zend_Registry::get('translator');
?>
<div id="flash-messeger"><?php echo $this->flashMessenger(); ?></div>
<div id="mapa">Configurações de Base/Filtros/<span>Editar Filtro</span></div>
<form action="" method="post" enctype="application/x-www-form-urlencoded" name="editFiltro" id="editFiltro">
<table width="700px" border="0" cellspacing="1" height="20px"> 
  <tr align="left">
    <td><?php echo $this->form->Campo;?></td>
      <td><?php echo $this->form->Expressao;?></td>
      <td><?php echo $this->form->PalavraChave;?></td>
      <td width="40%"><?php echo $this->form->Adicionar;?></td>    
  </tr>
</table>
</form>

<form action="<?php echo $this->url(array('action' => 'salvar','controller' => 'filtro','module' => 'admin'),null,true); ?>" method="post" enctype="application/x-www-form-urlencoded" name="salvarFiltro" id="salvarFiltro"> 
  <table class="grid" width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
    <tr>
      <th>Campo</th>
      <th>Tipo de Filtro</th>
      <th>Palavra-Chave</th>
      <th>Excluír</th>
      </tr>
    </thead>
    <?php foreach ($this->listaFiltro as $filtro) :?>
    <tr>     
      <td><?php echo $filtro['campo'];?></td>
      <td><?php echo $this->filtroConverteConectores($filtro['expressao']);?></td>
      <td><?php echo $filtro['palavraChave'];?></td>
      <td class="opcoes" width="8%" align="center"><a title="Excluír" href="javascript:void(0);" onclick="poup('/admin/filtro/excluir-regra/id/<?php echo $filtro['join_idfiltro'];?>/idjoin/',<?php echo $filtro['idjoin_filtro'];?>);"><img border="0" src="/imagens/icons/funnel-minus-icon.png"></a></td>
    </tr>
    <tr>
      <td colspan="4">
    <input type="hidden" name = "idjoin_filtro[]" id="idjoin_filtro[]" value="<?php echo $filtro['idjoin_filtro'];?>">  
    <?php if($filtro!= end($this->listaFiltro)){?>
	      <select name="conector[]" id="conector[]" title="E/OU">
	    	<option value="and" <?php if ($filtro['conector'] == 'and'){ echo 'selected="selected"';}?> label="E">E</option>
	   		 <option value="or" <?php if ($filtro['conector'] == 'or'){ echo 'selected="selected"';}?> label="OU">OU</option>
	      </select>
	      <?php }?>
      </td>      		
    </tr>   
    <?php endforeach;?>
  </table>
  <input style="font-weight:bold;" type="submit" name="salvar" id="salvar" value="Salvar" title="Salvar" >
</form>
<div id="confirme" title="<?php echo $translator->_('EXCLUIR_REGRA');?>">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo $translator->_('DELETAR_REGRA');?></p>
</div>